package com.ghck.shop.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.core.env.Environment;
import org.springframework.remoting.httpinvoker.HttpComponentsHttpInvokerRequestExecutor;
import org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean;

import com.ghck.shop.service.OrderService;


//@Configuration
public class RemoteConfig {
	
	@Autowired
	private Environment env;
	
	//@Autowired
    //private ShopCouponModifyService shopCouponModifyService;
		
    //@Autowired
	//private ShopServiceDoctorService shopServiceDoctorService;
    
//    @Autowired
//	private HttpComponentsHttpInvokerRequestExecutor httpInvokerRequestExecutor;
    @Bean
	public HttpComponentsHttpInvokerRequestExecutor httpInvokerRequestExecutor(){
		HttpComponentsHttpInvokerRequestExecutor httpInvokerRequestExecutor = new HttpComponentsHttpInvokerRequestExecutor();
		return httpInvokerRequestExecutor;
	}
	
	
	@Bean(name="shopOrderService")
	public OrderService shopOrderServiceBean(){
		HttpInvokerProxyFactoryBean bean = new HttpInvokerProxyFactoryBean();
		bean.setServiceInterface(OrderService.class);
		bean.setServiceUrl(env.getProperty("weitang.remote.shopOrderService"));
		bean.afterPropertiesSet();
		return (OrderService) bean.getObject();
	}
	
}